home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS26.ADF / DC / dc.c < prev    next >
C/C++ Source or Header  |  1989-01-26  |  3KB  |  147 lines

  1. /* Diskchange DF2:   V1.0
  2.  * 
  3.  * John Youells 
  4.  * (For folks with 5 1/4" drives)
  5.  * 
  6.  * SYSOP Jay                     - QLINK AmigaSIG
  7.  * crash!gryphon!pnet02!jyouells - PNET/USENET
  8.  * 
  9.  * 24 July 87
  10.  * This program was written using 
  11.  * ScreenShift 1.0
  12.  * by Anson Mah, as a template.
  13.  * It is completely in the Public Domain.
  14.  * Written for Manx C
  15.  *
  16.  * compile:  cc +L dc.c
  17.  * link   :  ln dc.o c32.lib
  18.  * Use FixHunk on the executable if its going to be
  19.  * used with expanded memory.
  20.  * Enjoy!
  21.  */
  22.  
  23.  
  24. #include <exec/types.h>
  25. #include <exec/memory.h>
  26. #include <intuition/intuition.h>
  27.  
  28. #include <functions.h>
  29. /* to get rid of those nasty ptr to int warnings */
  30.  
  31.  
  32. #define DCGADWIDTH   42 /* gadget proportions */
  33. #define DCGADHEIGHT  13
  34.  
  35.  
  36. struct IntuitionBase *IntuitionBase;
  37. struct GfxBase *GfxBase = NULL;
  38. struct Window *dcwin = NULL;
  39.  
  40. UWORD dcimagedata[] = {
  41.   
  42.    /* BitPlane 0 */
  43.    0x0000,0x0000,0x0000,
  44.    0x0000,0x0000,0x0000,
  45.    0x0FFF,0xFFFF,0xFC00,
  46.    0x1C1F,0x01E0,0xFE00,
  47.    0x3EEF,0xBFDE,0xFF00,
  48.    0x3EEF,0xBFFE,0xDF00,
  49.    0x3EEF,0x83F9,0xFF00,
  50.    0x3EEF,0xBFE7,0xFF00,
  51.    0x3EEF,0xBFEF,0xDF00,
  52.    0x1C1F,0x1FE0,0xFE00,
  53.    0x0FFF,0xFFFF,0xFC00,
  54.    0x0000,0x0000,0x0000,
  55.    0x0000,0x0000,0x0000,
  56.    /* BitPlane 1 */
  57.    0xFFFF,0xFFFF,0xFFC0,
  58.    0xF000,0x0000,0x03C0,
  59.    0xEFFF,0xFFFF,0xFDC0,
  60.    0xDFFF,0xFFFF,0xFEC0,
  61.    0xFFFF,0xFFFF,0xFFC0,
  62.    0xFFFF,0xFFFF,0xFFC0,
  63.    0xFFFF,0xFFFF,0xFFC0,
  64.    0xFFFF,0xFFFF,0xFFC0,
  65.    0xFFFF,0xFFFF,0xFFC0,
  66.    0xDFFF,0xFFFF,0xFEC0,
  67.    0xEFFF,0xFFFF,0xFDC0,
  68.    0xF000,0x0000,0x03C0,
  69.    0xFFFF,0xFFFF,0xFFC0
  70. };
  71.  
  72. struct Image dcimage = { 0, 0, 42, 13, 2, &dcimagedata[0], 0x03, 0x00, NULL };
  73.  
  74.  
  75. struct Gadget dcgadget = {
  76.    NULL, 28, 10, DCGADWIDTH, DCGADHEIGHT,  GADGIMAGE | GADGHCOMP ,
  77.    RELVERIFY,
  78.    BOOLGADGET, (APTR)&dcimage, NULL, NULL, 0, NULL,
  79.    0, NULL
  80. };
  81.  
  82. struct NewWindow dcwindef = {
  83.    130, 00,
  84.    100, 24,
  85.    3,    2,
  86.    CLOSEWINDOW | GADGETUP,
  87.    WINDOWDEPTH | WINDOWCLOSE | WINDOWDRAG | ACTIVATE | SMART_REFRESH
  88.    | RMBTRAP,
  89.    &dcgadget,
  90.    NULL,
  91.    (UBYTE *)"DC",
  92.    NULL, NULL,
  93.    0,0, 0,0,
  94.    WBENCHSCREEN
  95. };
  96.  
  97. void closestuff()
  98. {
  99.    if (dcwin)          CloseWindow(dcwin);
  100.    if (GfxBase)        CloseLibrary(GfxBase);
  101.    if (IntuitionBase)  CloseLibrary(IntuitionBase);
  102.    exit(0);
  103. }
  104.  
  105. void openstuff()
  106.  {
  107.    IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 33L);
  108.    GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 33L);
  109.  
  110.    if (IntuitionBase == NULL || GfxBase == NULL)
  111.        closestuff();
  112.  
  113.  
  114.    if (!(dcwin = (struct Window *)OpenWindow(&dcwindef)))
  115.        closestuff();   /* couldn't open window */
  116. }
  117.  
  118.   
  119.  
  120. void _main()
  121. {
  122.    struct IntuiMessage *msg;            
  123.    ULONG class, code;
  124.    BOOL  success;
  125.    openstuff();
  126.  
  127.    for (;;) {
  128.        WaitPort(dcwin->UserPort);
  129.        msg = (struct IntuiMessage *)GetMsg(dcwin->UserPort);
  130.        class = msg->Class;
  131.        code = msg->Code;
  132.        ReplyMsg(msg);
  133.  
  134.        switch (class) {
  135.            case CLOSEWINDOW:
  136.                closestuff();
  137.                break;
  138.            case GADGETUP:
  139.              success = Execute("DISKCHANGE df2:",0,0);
  140.                 break;
  141.              }
  142.              RefreshGadgets(&dcgadget, dcwin, NULL);
  143.              /* fall through */
  144.        }
  145.    }
  146.  
  147.